package com.hyt.it.ogt.ks.controller;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.ks.enums.BizStatusCode;
import com.hyt.it.ogt.ks.service.ICandidateLogAnswerService;
import com.hyt.it.ogt.opertaion.track.model.AnswerLogVO;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 * 轨迹表-答案轨迹表 前端控制器
 * </p>
 *
 * @author liteng
 * @since 2022-11-22
 */
@RestController
@Slf4j
@RequestMapping("/ks/candidate-log-answer")
public class CandidateLogAnswerController {

    @Resource
    private ICandidateLogAnswerService candidateLogAnswerService;

    @PostMapping("/saveAnswerLog")
    @ApiOperation(value = "保存答题轨迹日志", notes = "状态码：20000 成功 异常码：42130102 失败")
    @ApiOperationSort(1)
    public Object saveAnswerLog(@RequestBody List<AnswerLogVO> answerLogVOList) {
        log.info("保存答题轨迹日志，收到参数为:【{}】,", answerLogVOList);
        try {
            return ApiResponse.builder()
                    .code(BizStatusCode.KS_SUCCESS_OK.getCode())
                    .data(candidateLogAnswerService.saveAnswerLog(answerLogVOList))
                    .build();
        } catch (Exception ex) {
            log.error("保存答题轨迹日志异常，收到参数为:【{}】,", answerLogVOList, ex);
            return ApiResponse.builder()
                    .code(BizStatusCode.SAVE_ANSWER_LOG_FAIL.getCode())
                    .build();
        }
    }

}
